package edu.gatech.volt2.drdoommgt.gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JTextField;
import javax.swing.JButton;

public class NameWindow extends JFrame implements INameView {

	private JPanel contentPane;
	private JTextField firstNameTextField;
	private JTextField middleNameField;
	private JTextField lastNameField;
	private JButton submitButton;
	private JButton cancelButton;


	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					NameWindow frame = new NameWindow();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public NameWindow() {
		setTitle("Dr. Doom Management");
		setBounds(100, 100, 350, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(0, 0, 334, 262);
		contentPane.add(panel);
		panel.setLayout(null);
		
		JLabel instructionLabel = new JLabel("Enter Patient's Full Name");
		instructionLabel.setHorizontalAlignment(SwingConstants.CENTER);
		instructionLabel.setBounds(85, 24, 140, 20);
		panel.add(instructionLabel);
		
		JLabel firstNameLabel = new JLabel("First");
		firstNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
		firstNameLabel.setBounds(49, 74, 46, 14);
		panel.add(firstNameLabel);
		
		firstNameTextField = new JTextField();
		firstNameTextField.setBounds(125, 71, 147, 20);
		panel.add(firstNameTextField);
		firstNameTextField.setColumns(10);
		
		JLabel middleNameLabel = new JLabel("Middle");
		middleNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
		middleNameLabel.setBounds(49, 105, 46, 14);
		panel.add(middleNameLabel);
		
		middleNameField = new JTextField();
		middleNameField.setBounds(125, 102, 147, 20);
		panel.add(middleNameField);
		middleNameField.setColumns(10);
		
		JLabel LastNameLabel = new JLabel("last");
		LastNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
		LastNameLabel.setBounds(49, 136, 46, 14);
		panel.add(LastNameLabel);
		
		lastNameField = new JTextField();
		lastNameField.setBounds(125, 133, 147, 20);
		panel.add(lastNameField);
		lastNameField.setColumns(10);
		
		submitButton = new JButton("Submit");
		submitButton.setBounds(49, 200, 89, 23);
		panel.add(submitButton);
		
		cancelButton = new JButton("Cancel");
		cancelButton.setBounds(183, 200, 89, 23);
		panel.add(cancelButton);
	}

	@Override
	public void showSelf() {
		this.setVisible(true);		
	}

	@Override
	public void addListener(ActionListener al) {
		cancelButton.addActionListener(al);
		submitButton.addActionListener(al);	
	}

	@Override
	public void hideSelf() {
		this.setVisible(false);	
	}

	@Override
	public JButton getCancelButton() {
		return cancelButton;
	}

	@Override
	public JButton getSubmitButton() {
		return submitButton;
	}

	@Override
	public JTextField getFirstNameTextField() {
		return firstNameTextField;
	}
	
	/**
	 * @return the middleNameField
	 */
	public JTextField getMiddleNameField() {
		return middleNameField;
	}


	@Override
	public JTextField getLastNameField() {
		return lastNameField;
	}
}
